from pydantic import BaseModel, Field
from schemas import GMT


class CronTabIn(BaseModel):
    """ 共享模型字段 """
    name: str = Field(example='定时任务名称')
    description: str = Field(example='定时任务描述')
    isExecuteForbiddenedCase: bool = Field(default=False, example='是否执行禁用的用例')
    testCaseSuiteIdList: list = Field(default=[], example='任务执行的用例suiteId列表')
    testDomain: str = Field(example='测试域名')
    next_run_time: str = Field(example='下次执行时间')
    triggerType: str = Field(example='触发类型')
    interval: int = Field(example='触发间隔')
    alarmMailList: list = Field(default=[], example='告警邮箱列表')
    status: bool = Field(default=True, example='状态')
    createName: str = Field(example='创建者')
    updateName: str = Field(example='最后更新人')
    projectId: int = Field(example='项目ID')


class CronTabCreate(CronTabIn):
    """ 添加数据时的字段验证 """
    pass


class CronTabUpdate(CronTabIn):
    """ 更新数据的字段验证 """
    pass


class CronTabOut(CronTabIn, GMT):
    """ 查询数据的字段验证 """
    id: int = Field(..., example='编号')

    class Config:
        orm_mode = True  # 是否使用orm模型(结果为字典类型)
